class 班级(object):
    __count = 0

    def __init__(self):
        print("init")

    @classmethod
    def increment_stu_num(cls):
        """
            学生的人数累加
        :return:
        """
        cls.__count += 1

    @classmethod
    def get_count(cls):
        return cls.__count

    def __new__(cls, *args, **kwargs):
        print("new")
        # 加一行代码:调用上面的人数增长
        班级.increment_stu_num()
        # 如果这里返回的是None那init将不执行
        return super(班级,cls).__new__(cls)





class Student(班级):
    # init哪怕不写也是存在的.默认就是无参的.
    pass


# 类的实例化是先执行new在执行init
s1 = Student() # 创建子类实例一定会先创建父类实例.
s2 = Student()
s3 = Student()
s4 = Student()
s5 = Student()

print(班级.get_count())